<!--
 * @Author: tkp
 * @Date: 2024-03-29 10:17:43
-->
<template>
  <div>
    <el-form :model="queryForm" label-position="right" :rules="rules" ref="ruleForm" label-width="120px">
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item prop="menuName" label="菜单名称:">
            <Input v-model="queryForm.menuName" disabled size="medium" clearable placeholder="请输入菜单名称"></Input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="24">
          <el-form-item prop="sortIndex" label="排序:">
            <Input v-model="queryForm.sortIndex" size="medium" type="number" clearable placeholder="请输入排序"></Input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-form-item>
        <el-button type="primary" size="medium" @click="okPop">确认</el-button>
        <el-button size="medium" @click="closePop">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  props: {
    data: {
      type: Object | String,
      required: true
    },
  },
  data() {
    return {
      queryForm: {
        menuName: '',
        sortIndex: '',
        level: '',
        menuId: '',
      },
      rules: {
        menuName: [
          { required: true, message: '此项为必填' },
        ],
        sortVal: [
          { required: true, message: '此项为必填' },
        ],
      },
    }
  },
  mounted() {
    this.queryForm.menuId = this.data.menuId
    this.queryForm.sortIndex = this.data.sortIndex
    this.queryForm.menuName = this.data.menuName
    this.queryForm.level = this.data.level
  },
  methods: {
    closePop() {
      this.$emit('editSortData', '')
    },
    okPop() {
      this.$refs['ruleForm'].validate((valid) => {
        if (valid) {
          this.$emit('editSortData', this.queryForm)
        } else {
          this.messageWarnPop('请填写完整')
          return false;
        }
      });
    },
  }
}
</script>

<style lang="scss" scoped>
.fenrun_class {
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 5px;
  .title {
    width: 100px;
  }
  .end {
    color: #999999;
  }
}
</style>
